package com.philips.servlet;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

public class DowloadServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			File file=new File(req.getRealPath("/")+"data/json");
			File file2=new File(req.getRealPath("/")+"data/excel");
			List jsonlist=new ArrayList();
			List excellist=new ArrayList();
			for (int i = 0; i < file.list().length; i++) {
				jsonlist.add(file.list()[i]);
			}
			for (int i = 0; i < file2.list().length; i++) {
				excellist.add(file2.list()[i]);
			}
			Map airMap=new HashMap();
			airMap.put("jsondata", jsonlist);
			airMap.put("exceldata", excellist);
			String json=JSON.toJSONString(airMap);
			resp.getWriter().print(json);
	}
}
